class Solution {
public:
    int maxArea(vector<int>& height)
    {
        int n = height.size();
        int left = 0, right = n - 1;
        int max = 0;
        while (right > left)
        {
            int v = ((right - left) * min(height[left], height[right]));
            max = fmax(max, v);
            if (height[left] > height[right])
            {
                right--;
            }
            else
            {
                left++;
            }

        }
        return max;
    }
};